#!/usr/bin/env python
# -*- coding: utf-8 -*-

def select_pubnet_host(groups, hostvars, filter_groups = []):
    if isinstance(groups, dict):
        for key, child in groups.items():
            if filter_groups and key not in filter_groups:
                continue
            for h in child:
                if hostvars[h].get('no_proxy', False):
                    return h
    return ''

class FilterModule(object):
    def filters(self):
        return {
            'select_pubnet_host': select_pubnet_host
        }
